﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    事件处理列表
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        EventRecord er = (EventRecord)ViewData["eventRecord"];
        Dictionary<long, string> recorders = (Dictionary<long, string>)ViewData["recorders"];
        User user = (User) ViewData["user"];
        IEnumerable<EventDailyRecord> eventDailyRecords = (IEnumerable<EventDailyRecord>)ViewData["eventDailyRecords"];
    %>

    
    <table id="spdata" cellpadding="4" cellspacing="0" class="com_from_table3" style="vertical-align:middle;width:1120px;">
        <tr>
            <th style="width:60px;">进程</th>
            <th style="width:120px;">时间</th>
            <th style="width:600px;">情况描述</th>
            <th style="width:135px;">记录人员</th>
            <th style="width:68px;">图片数量</th>
            <th style="width:50px;">进度</th>
            <th style="width:65px;">状态</th>
        </tr>
        <%
            int i = 0;
            foreach (EventDailyRecord e in eventDailyRecords)
          {
              i++;
              string userName = "";
              recorders.TryGetValue(e.RecorderId, out userName);
        %>
        <tr>
            <td class="textCenter"><%if (e.Status != 3 && !(er.Status == 0 && e.Status == 0)) { %><%=Html.ActionLink("第" + ((e.OccurredDate.Date - er.OccurredDate.Date).Days + 1) + "天", "Detail", new { eventId = er.Id, dailyId = e.Id })%><%}else{ %><%="第" + ((e.OccurredDate.Date - er.OccurredDate.Date).Days + 1) + "天"%><%} %></td>
            <td class="textCenter"><%=e.OccurredDate.ToString("yyyy-MM-dd HH:mm") %></td>
            <td style="padding-left:0.8em;"><%=Html.CutString(e.Description, 36, "...") %></td>
            <td style="padding-left:0.8em;"><%=userName%></td>
            <td class="textCenter"><%=e.Status == 0 || e.Status == 3 ? "" : e.PicNum.ToString()%></td>
            <td class="textCenter"><%=e.Status == 0 || e.Status == 3 ? "" : e.Progress.ToString() + "%"%></td>
            <td class="textCenter">
            <%if (er.Status == 0 && e.Status == 0 && user.RoleId == (int)RoleEnum.Recorder)
              { %>
              <%=Html.ActionLink("记录", "AddDailyRecord", new { eventId = e.EventId})%>
            <%}
              else if (er.Status == 0 && e.Status == 1 && e.CreatedDate.Date == DateTime.Now.Date && user.RoleId == (int)RoleEnum.Recorder)
              {
            %>
              <%=Html.ActionLink("修改", "EditDailyRecord", new { id = e.Id })%>
              <%=Html.ActionLink("删除", "DeleteDailyRecord", new { id = e.Id }, new { style = "margin-left:3px" })%>
            <%
               }
              else
              {
            %>
            <%= (e.Status == 1 ? "已记录" : (e.Status == 2 ? "事件结束" : (e.Status == 3 ? "确认结束" : "")))%>
            <%
                }
            %>
            </td>
        </tr>
        <%} %>  
    </table>

    <script language="javascript" type="text/javascript">
        jQuery(function ($) {
            refreshMenuPage();
        });
    </script>
</asp:Content>
